package com.klun.aop.JDKProxy1;

import com.klun.aop.speak.SpeakSomething;
import com.klun.aop.speak.SpeakSomethingImpl;
import org.springframework.aop.framework.DefaultAopProxyFactory;

public class Client {
    public static void main(String[] args){
        JDKProxy1();
        System.out.println();
        JDKProxy2();
    }

    private static void staticProxy(){
        Star realStar = new RealStar();
        ProxyStar proxyStar = new ProxyStar(realStar);
        proxyStar.sing();
    }

    private static void JDKProxy1(){
        Star realStar = new RealStar();
        Star proxyInstance = (Star)new JdkProxyHandler(realStar).getProxyInstance();
        proxyInstance.sing();
    }

    private static void JDKProxy2(){
        SpeakSomething ss = new SpeakSomethingImpl();
        SpeakSomething proxyInstance = (SpeakSomething)new JdkProxyHandler(ss).getProxyInstance();
        proxyInstance.sayHi();
        proxyInstance.sayBye();
    }
}
